﻿using System;
using System.Web.UI;

namespace ADEVSO.Web.UI
{
    public class PopupWindow
    {
        #region Variables

        private ClientScriptManager _ClientScript;
        private Boolean _Center = true;
        private Boolean _Resizable = true;
        private Boolean _Status = true;
        private int _Height = 375;
        private int _Width = 75;

        private const String _Script = "<script>window.showModalDialog('{0}', null, 'center:{1};resizable:{2};status:{3};dialogWidth:{4}px;dialogHeight:{5}px');</script>";
        private String _PageUrl;

        #endregion
        

        #region Constructors

        public PopupWindow(ClientScriptManager ClientScript, String PageUrl)
        {            
            _ClientScript = ClientScript;
            _PageUrl = PageUrl;
        }

        #endregion

        
        #region Properties

        public Boolean Center
        {
            get
            {
                return _Center;
            }
            set
            {
                _Center = value;
            }
        }

        public Boolean Resizable
        {
            get
            {
                return _Resizable;
            }
            set
            {
                _Resizable = value;
            }
        }

        public Boolean Status
        {
            get
            {
                return _Status;
            }
            set
            {
                _Status = value;
            }
        }

        public int Height
        {
            get
            {
                return _Height;
            }
            set
            {
                _Height = value;
            }
        }

        public int Width
        {
            get
            {
                return _Width;
            }
            set
            {
                _Width = value;
            }
        }

        #endregion


        #region Methods

        public void Show()
        {
            String FinalScript = String.Format(_Script, new Object[] { _PageUrl, Center, Resizable, Status, Width, Height });
            _ClientScript.RegisterClientScriptBlock(typeof(String), "PopupWindow", FinalScript);
        }

        #endregion
    }
}
